package 华为OD机试B卷复用题.基础题;

import utils.MyUtil;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

public class HJ33_寻找身高相近的小朋友 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(new File("src/main/java/华为OD机试B卷复用题/基础题/input/33.txt"));
        MyUtil.START();
        Solution(in);
        MyUtil.END();
    }

    // 很简单，自定义排序
    static void Solution(Scanner in) {
        Integer[] arr = new Integer[100];
        int k = 0;
        for (int i = 50; i < 150; i++) {
            arr[k++] = i;
        }
        Arrays.sort(
                arr,
                (a, b) -> {
                    int num1 = Math.abs(a - 100);
                    int num2 = Math.abs(b - 100);
                    return num1 != num2 ? num1 - num2 : a - b;
                });
        System.out.println(Arrays.toString(arr));
    }
}
